{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "98c066af-6eb9-48e1-9c0c-4841ed96b375",
   "metadata": {},
   "source": [
    "# 数字数据类型用于存储数值\n",
    "数据类型是不允许改变的，这就意味着如果改变数字数据类型的值，将重新分配内存空间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "d001bc21-7f4d-4bd8-8850-a542b156ee3c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1, 2)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 以下实例在变量赋值时 Number 对象将被创建\n",
    "number1 = 1\n",
    "number2 = 2\n",
    "number1, number2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0f169133-bab0-4a2c-93f8-1213a559ca06",
   "metadata": {},
   "source": [
    "# del语句删除一些数字对象的引用\n",
    "del var1[,var2[,var3[....,varN]]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "b84cfc6e-996c-4886-b980-4230ca905a7c",
   "metadata": {},
   "outputs": [],
   "source": [
    "del number1, number2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f3a2904d-954c-480b-a41f-342d174e8860",
   "metadata": {},
   "source": [
    "# Number 数值类型\n",
    "* 整型(int) - 通常被称为是整型或整数，是正或负整数，不带小数点。Python3 整型是没有限制大小的，可以当作 Long 类型使用，所以 Python3 没有 Python2 的 Long 类型。\n",
    "* 布尔(bool)是整型的子类型\n",
    "* 浮点复数( (complex)) - 复数由实数部分和虚数部分构成，可以用a + bj,或者complex(a,b)表示， 复数的实部a和虚部b都是浮点型。型(float) - 浮点型由整数部分与小数部分组成，浮点型也可以使用科学计数法表示（2.5e2 = 2.5 x 102 = 250）\n",
    "* 复数( (complex)) - 复数由实数部分和虚数部分构成，可以用a + bj,或者complex(a,b)表示， 复数的实部a和虚部b都是浮点型。\n",
    "   * 复数由实数部分和虚数部分构成，可以用a + bj,或者complex(a,b)表示， 复数的实部a和虚部b都是浮点型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "86aa0d7f-4497-4f99-8d08-22d41467fcdd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2575"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 可以使用十六进制和八进制来代表整数\n",
    "number = 0xA0F # 十六进制\n",
    "number"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "5e068e0d-5d16-4d29-a8a4-16b12be1f51d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "31"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "number=0o37 # 八进制\n",
    "number"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d696b8f2-f95e-46aa-a81d-e5834515bb48",
   "metadata": {},
   "source": [
    "bool 是 int 的子类，True 和 False 可以和数字相加"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "8cdb19c9-b259-4498-b31e-af0975f1a2f8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "True == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "c70b630a-864f-45c8-9d96-5bd297476a7d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "False == 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "406ec0b8-4149-4128-b175-45ff61715bd2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "True + 1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f372a6a4-8bde-4d79-845b-98253bd5b000",
   "metadata": {},
   "source": [
    "# 数字类型转换\n",
    "* int(x) 将x转换为一个整数\n",
    "* float(x) 将x转换到一个浮点数\n",
    "* complex(x) 将x转换到一个复数，实数部分为 x，虚数部分为 0\n",
    "* complex(x, y) 将 x 和 y 转换到一个复数，实数部分为 x，虚数部分为 y。x 和 y 是数字表达式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "a86e4abe-92ca-4f8f-9a4a-5146119d1b92",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "number = int(1.2)\n",
    "number"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0ba7f511-fa95-4dbf-acf9-4d2300ab58a0",
   "metadata": {},
   "source": [
    "# 数字运算\n",
    "* +：加法\n",
    "* -：减法\n",
    "* *：乘法\n",
    "* /：除法 / 总是返回一个浮点数\n",
    "* //: 得到除法的整数的结果\n",
    "* %：取余\n",
    "* **：乘方，进行幂运算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "5139cc17-7c8a-4941-884b-d07ba1a2673c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.5"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "number = 7 / 2\n",
    "number"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "34673e75-61fb-4bf0-95ef-d81ece7fdd56",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "number = 7 // 2\n",
    "number"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "e9b1551c-5083-4e25-8b5e-8af79d1243e0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "number = 2 ** 3\n",
    "number"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6844337c-3f9f-46db-ac1e-a3eab1539ae5",
   "metadata": {},
   "source": [
    "不同类型的数混合运算时会将整数转换为浮点数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "bc6a7172-5c66-422b-b983-340383c65cfb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "11.25"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3 * 3.75"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0385b3a0-98c7-47fb-99ad-3ca3c5650bd2",
   "metadata": {},
   "source": [
    "在交互模式中，最后被输出的表达式结果被赋值给变量 _ \n",
    "\n",
    "_ 变量应被用户视为只读变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "93ba4d8d-3b75-4fc8-bb9c-dea914fc919a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "11.25"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "_"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ca7ac86d-4af7-4d33-b3b9-ce63d0f62d39",
   "metadata": {},
   "source": [
    "# 数学函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e4e05d9a-18da-4fb9-9c1d-557cd060c443",
   "metadata": {},
   "outputs": [],
   "source": [
    "abs, "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "df77ac21-66ed-419d-8a4c-3b7a2f4dbe7f",
   "metadata": {},
   "source": [
    "# 随机数函数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "706b3b29-f8fd-4c7f-8948-5cde9ea2b780",
   "metadata": {},
   "source": [
    "# 三角函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5f6cc5fa-84db-4c3e-8f42-f6003fa5d5d5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
